<?php
/**
 * NetBiz Framework
 * Copyright (C) 20009 - 2010 NetBiz
 * 
 * All rights reserved.
 */

/*define('FRM_EX_NO_ACTION'		,	 1001);
define('FRM_EX_NO_CONTROLLER'		,	 1002);
define('FRM_EX_LOAD_MODULE'		,	 2001);
define('FRM_EX_DATABASE_CONNECTION'	,	 3001);
define('FRM_EX_PARAMETER'		,	10001);*/

class FRM_Exception extends Exception
{
	const FORBIDDEN					= 403   ;
	const NOT_FOUND					= 404   ;

	const NO_ACTION					= 1001  ;
	const NO_CONTROLLER				= 1002  ;
	const LOAD_MODULE				= 2001  ;
	const DATABASE_CONNECTION		= 3001  ;
	const CONFIG_VAR				= 4001  ;
	const CONFIG_DOMAIN				= 4002	;
	const CONFIG_TYPE				= 4003  ;
	const CONFIG_LOCK				= 4004  ;
	const REGISTRY_VAR				= 5001  ;
	const SQL_ERROR					= 6001  ;
	const PARAMETER					= 10001 ;
	const FILE_PERMISSION			= 90002 ;

	protected $_extra = NULL;

	public function __construct($message = NULL, $code = 0, $extra = NULL)
	{
		parent::__construct($message,$code);
		$this->_extra = FRM_String::extract($extra);
	}

	public function __toString()
	{
		if ($this->_extra)
		{
			return parent::__toString().PHP_EOL.PHP_EOL.'Extra:'.PHP_EOL.$this->_extra;
		}
		else
		{
			return parent::__toString();
		}
	}

	public function getExtra()
	{
		return $this->_extra;
	}
}